<template>
  <footer class="footer">
    <span class="todo-count">剩余<strong>数量值:{{list.length}}</strong></span>
    <ul @click="filterState"  class="filters">
      <li>
        <a
        @click="isSel='all'" 
        :class="{selected:isSel==='all'}" 
        href="javascript:;">全部</a>
      </li>
      <li>
        <a
        @click="isSel='no'"
        :class="{selected:isSel==='no'}" 
         href="javascript:;">未完成</a>
      </li>
      <li>
        <a
        @click="isSel='yes'"
        :class="{selected:isSel==='yes'}" 
         href="javascript:;">已完成</a>
      </li>
    </ul>
    <button @click="clearClick" class="clear-completed">清除已完成</button>
  </footer>
</template>

<script>
import {mapState} from "vuex"
export default {
  data(){
    return {
     isSel:"all"
    }
  },
  computed:{
    ...mapState('todo',['list'])
  },
  methods:{
    filterState(){
      this.$store.commit("todo/changeState", this.isSel)
    },
    // changeSel(val){
    //   // this.$store.commit("todo/changeTask",val)
    // },
    clearClick(){
      this.$store.commit('todo/clearDone');
    }
  }
};
</script>